<!--
  Created by IntelliJ IDEA.
  User: gaoxiang
  Date: 19-12-23
  Time: 下午1:52
-->
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>后台登录</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />
    <link th:href="@{/static/favicon.ico}" rel="shortcut icon" />

    <!-- BEGIN GLOBAL MANDATORY STYLES -->
    <link th:href="@{/metronic/global/plugins/font-awesome/css/font-awesome.min.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{/metronic/global/plugins/simple-line-icons/simple-line-icons.min.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{/metronic/global/plugins/bootstrap/css/bootstrap.min.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{/metronic/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css}" rel="stylesheet" type="text/css"/>
    <!-- END GLOBAL MANDATORY STYLES -->

    <!-- BEGIN PAGE LEVEL PLUGINS -->
    <link th:href="@{/metronic/global/plugins/select2/css/select2.min.css}" rel="stylesheet" type="text/css" />
    <link th:href="@{/metronic/global/plugins/select2/css/select2-bootstrap.min.css}" rel="stylesheet" type="text/css" />
    <!-- END PAGE LEVEL PLUGINS -->

    <!-- BEGIN THEME GLOBAL STYLES -->
    <link th:href="@{/metronic/global/css/components-rounded.min.css}" rel="stylesheet" id="style_components" type="text/css" />
    <link th:href="@{/metronic/global/css/plugins.min.css}" rel="stylesheet" type="text/css" />
    <!-- END THEME GLOBAL STYLES -->

    <!-- BEGIN PAGE LEVEL STYLES -->
    <link th:href="@{/metronic/pages/css/login.min.css}" rel="stylesheet" type="text/css" />
    <!-- END PAGE LEVEL STYLES -->

</head>
<body class=" login">
<!-- BEGIN LOGO -->
<div class="logo">
    <a href="/adminLoginPage">
        <img th:src="@{/a.jpg}" alt="" />
    </a>
</div>
<!-- END LOGO -->
<!-- BEGIN LOGIN -->
<div class="content">
    <!-- BEGIN LOGIN FORM -->
    <form class="login-form" action="/login/adminLogin" method="post" id="loginForm">

        <h3 class="form-title font-green">请登录</h3>
        <div class="form-group">
            <!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
            <label class="control-label visible-ie8 visible-ie9">Username</label>
            <input class="form-control form-control-solid placeholder-no-fix" type="text" autocomplete="off" placeholder="您的用户名" name="userName" /> </div>
        <div class="form-group">
            <label class="control-label visible-ie8 visible-ie9">Password</label>
            <input class="form-control form-control-solid placeholder-no-fix" type="password" autocomplete="off" placeholder="您的密码" name="password" /> </div>
        <div class="form-actions">
            <button type="button" class="btn green btn-sm uppercase" onclick="loginForm()">
                <i id="login_btn_ico" class="fa fa-hand-o-right"></i> 登陆
            </button>
            <label class="rememberme check mt-checkbox mt-checkbox-outline">
                <input type="checkbox" name="remember" value="1" />记住密码
                <span></span>
            </label>
        </div>
    </form>
    <!-- END LOGIN FORM -->

</div>
<div class="copyright">  &copy; 2017-2020 lianxinyi.com.cn 版权所有 鲁ICP备 ** 号 </div>

<!-- BEGIN CORE PLUGINS -->
<script th:src="@{/metronic/global/plugins/jquery.min.js}" type="text/javascript"></script>
<script th:src="@{/metronic/global/plugins/bootstrap/js/bootstrap.min.js}" type="text/javascript"></script>
<script th:src="@{/metronic/global/plugins/js.cookie.min.js}" type="text/javascript"></script>
<script th:src="@{/metronic/global/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js}" type="text/javascript"></script>
<script th:src="@{/metronic/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js}" type="text/javascript"></script>
<script th:src="@{/metronic/global/plugins/jquery.blockui.min.js}" type="text/javascript"></script>
<script th:src="@{/metronic/global/plugins/bootstrap-switch/js/bootstrap-switch.min.js}" type="text/javascript"></script>
<!-- END CORE PLUGINS -->

<!-- BEGIN PAGE LEVEL PLUGINS -->
<script th:src="@{/metronic/global/plugins/jquery-validation/js/jquery.validate.min.js}" type="text/javascript"></script>
<script th:src="@{/metronic/global/plugins/jquery-validation/js/additional-methods.min.js}" type="text/javascript"></script>
<script th:src="@{/metronic/global/plugins/select2/js/select2.full.min.js}" type="text/javascript"></script>
<!-- END PAGE LEVEL PLUGINS -->

<!-- BEGIN THEME GLOBAL SCRIPTS -->
<script th:src="@{/metronic/global/scripts/app.min.js}" type="text/javascript"></script>
<!-- END THEME GLOBAL SCRIPTS -->

<!-- BEGIN THEME LAYOUT SCRIPTS -->
<script th:src="@{/plugins/layer/layer.js}"></script>
<script th:src="@{/js/tools.js}"></script>
<!-- END THEME LAYOUT SCRIPTS -->
<script>

    $(document).ready(function () {
        console.log("请先登陆。")
    });

    /**
     * 登陆
     * @returns {boolean}
     */
    function loginForm() {
        var param = tools.formParams("loginForm")

        var userName = param["userName"];
        var password = param["password"];
        var remember = param["remember"];

        //验证
        if (userName.trim() == "") {
            layer.msg("请输入用户名",{icon:2});
            return false;
        }
        if (password.trim() == "") {
            layer.msg("请输入密码",{icon:2});
            return false;
        }

        //开始登陆样式
        $("#login_btn_ico").attr("class", "fa fa-spinner fa-spin");

        $.ajax({
            type : "post",
            url : "/login/adminLogin",
            data : {"userName":userName,"password":getPassword(password),"remember":remember},
            dataType : "json",
            success : function(data){

                if (data.success) {
                    layer.msg('登陆成功！',{icon: 1,time:1000}, function(){
                        window.location.href = "/";
                    });

                } else {
                    $("#login_btn_ico").attr("class", "fa fa-arrow-circle-right");
                    $("#password").val("");
                    tools.errorTip(data);
                }
            }
        });
    }

    function getPassword(password){
        var pwdMd5 = "";
        $.ajax({
            type : "post",
            url : "/login/md5",
            data : {pwd:password},
            async : false,
            success : function(data){
                pwdMd5 = data;
            }
        });
        return pwdMd5;
    }


    //绑定回车事件
    $(document).keydown(function (event) {
        if (event.keyCode == 13) {
            loginForm();
        }
    });
</script>
</body>
</html>